package cq.zhcqk.activity;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;

import cq.zhcqk.R;
import cq.zhcqk.base.BaseActivity;

/**
 * Created by zhangle on 2017/12/9.
 */
public class SQ_FW_WaterActivity extends BaseActivity{
    private WebView webView;
    private String url = "alipays://platformapi/startapp?appId=20000193&url=/www/setNewAccount.htm?subBizType=GAS";
    @Override
    protected void initView() {
        setContentView(R.layout.activity_sq_fw);
        webView = (WebView) findViewById(R.id.water_web);
    }

    @Override
    protected void initData() {
//        webView.loadUrl(url);
        boolean visit = checkAliPayInstalled(context);
        if(visit){
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
        }
    }

    //判断是否安装支付宝app
    public static boolean checkAliPayInstalled(Context context) {
        Uri uri = Uri.parse("alipays://platformapi/startApp");
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        ComponentName componentName = intent.resolveActivity(context.getPackageManager());
        return componentName != null;
    }
}
